# -*- coding: utf-8 -*-
#!/usr/bin/env python


def class_init_decorator(func):
    def new(self, *args, **kwargs):
        print self.__class__.__name__, 'init'
        return func(self, *args, **kwargs)
    return new


class BaseAttribute(object):

    @class_init_decorator
    def __init__(self):
        super(BaseAttribute, self).__init__()

    def __getattribute__(self, name):
        print '__getattribute__:', name
        return object.__getattribute__(self, name)

    @property
    def a(self):
        return 'a propery'

    def b(self):
        return 'b'


class BaseAttributeChild(BaseAttribute):

    @class_init_decorator
    def __init__(self):
        super(BaseAttributeChild, self).__init__()

    def __getattribute__(self, name):
        print 'child __getattribute__:', name
        return object.__getattribute__(self, name)


class BaseGetAttr(object):

    @class_init_decorator
    def __init__(self):
        super(BaseGetAttr, self).__init__()

    def __getattr__(self, name):
        print '__getattr__:', name
        return object.__getattribute__(self, name)

    @property
    def a(self):
        return 'a propery'

    def b(self):
        return 'b'


class BaseGetAttrChild(BaseGetAttr):

    @class_init_decorator
    def __init__(self):
        super(BaseGetAttrChild, self).__init__()

    def __getattr__(self, name):
        print 'child __getattr__:', name
        return object.__getattribute__(self, name)

base_attribute_obj = BaseAttribute()
base_attribute_child_obj = BaseAttributeChild()

base_getattr_obj = BaseGetAttr()
base_getattr_child_obj = BaseGetAttrChild()
